/**
 * 比较字符串大小
 * 12-2-33-45
 * 12-2-22-45
 */

function *walk(str) {
  let s = '';
  for (let n of str) {
    if (n !== '-') {
      s += n;
    } else {
      yield Number(s);
      s = '';
    }
  }
  // 最后一位
  if (s) {
    yield Number(s);
  }
}

let iter = walk('12-2-33-45');
console.log(iter.next());
console.log(iter.next());
console.log(iter.next());
console.log(iter.next());
console.log(iter.next());
